# CSDN 作业1  8种 九九乘法表
# for 左正三角 No.1
for i in range(1,10):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(j,i,j*i),end=" ")
    print()

print("=="*40)


# for 左倒三角 No.2
for i in range(9,0,-1):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(j,i,j*i),end=" ")
    print()

print("=="*40)


# for 右正三角 No.3
for i in range(1,10):
    for j in range(9,0,-1):
        if j <= i:
            print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        else:
            # 占位 ‘数字 * 数字 =’  4位
            print("{:4}{:<4}".format('',""),end=" ")
    print()

print("=="*40)


# for 右倒三角 No.4
for i in range(1,10):
    for j in range(9,0,-1):
        if j <= 10 - i:
            print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        else:
            # 站位 数字 * 数字 =  工4位
            print("{:4}{:<4}".format('',""),end=" ")
    print()

print("=="*40,"while 左正三角 No.5")
# while 左正三角 No.5
i = 1
while i < 10:
    j = 1
    while j <= i:
        print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        j += 1
    i += 1
    print()

print("=="*40,"while 左倒三角 No.6")
# while 左正三角 No.6
i = 9
while i > 0:
    j = 1
    while j <= i:
        print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        j += 1
    i -= 1
    print()


print("=="*40,"while 右正三角 No.7")
# while 右正三角 No.7
i = 1
while i < 10:
    j = 9
    while j > 0:
        if j <= i:
            print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        else:
           print("{:4}{:<4}".format("",""),end=" ")
        j -= 1
    i += 1
    print()

print("=="*40,"while 右倒三角 No.8")
# while 右倒三角 No.8
i = 9
while i > 0:
    j = 9
    while j > 0:
        if j <= i:
            print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        else:
           print("{:4}{:<4}".format("",""),end=" ")
        j -= 1
    i -= 1
    print()